package com.hy.video.monitor.domain.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.hy.video.monitor.domain.Permission;
import com.hy.video.monitor.domain.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

@JsonIgnoreProperties(ignoreUnknown = true)
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PermissionsDto implements Serializable {

    private static final long serialVersionUID = 1L;

    private Long id;

    private String permissionName;

    private String displayName;

    public static Function<Permission, PermissionsDto> fromPermissions = (permission) -> PermissionsDto.builder()
        .id(permission.getId())
        .permissionName(permission.getAuthority())
        .displayName(permission.getDisplayName())
        .build();
}
